package com.ty.day2.home;

import java.sql.Time;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/23 16:30
 */
public class Task1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入一行字符：");
        String string = sc.nextLine();
        int leter=0,digit=0,space=0,other=0;
        char x;
        for (int i = 0; i < string.length(); i++) {
             x=string.charAt(i);
             if (x>='a'&&x<='z'||x>='A'&&x<='Z'){//判断是否是字母
                 leter++;
             }else if (x>='0'&&x<='9'){//判断是否为数字
                 digit++;
             } else if (x == ' ') {//空格
                 space++;
             }else {//其他字符
                 other++;
             }
        }
        System.out.println("数字"+digit+"个");
        System.out.println("字母"+leter+"个");
        System.out.println("空格"+space+"个");
        System.out.println("其他字符"+other+"个");

    }
}
